﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TutorialFour
{
    /**
 * LowPassSP is a single pole low pass filter. It is not super great, but it gets the job 
 * done.
 * 
 *
 */
public class LowPass : IIRFilter 
{
  /**
   * Constructs a low pass filter with a cutoff frequency of <code>freq</code>
   * that will be used to filter audio recorded at <code>sampleRate</code>.
   * 
   * @param freq
   *          the cutoff frequency
   * @param sampleRate
   *          the sample rate of the audio that will be filtered
   */
    public LowPass(float freq, float sampleRate) : base(freq, sampleRate)
	{

	}

    protected override void calcCoeff() 
	{
    float fracFreq = frequency()/sampleRate();
	  float x = (float)Math.Exp(-2*Math.PI*fracFreq);
	  a = new float[] { 1 - x };
	  b = new float[] { x };
	}
}
}
